//
//import org.babyfish.jimmer.sql.runtime.ScalarProvider
//import org.springframework.stereotype.Component
//
//@Component
//class BasicEnumScalarProvider<T : Enum<T>> : ScalarProvider<BaseEnum<T>, Any> {
//
//    override fun toScalar(sqlValue: Any): BaseEnum<T>? {
//        val clazz = scalarType.javaClass
//        if (!clazz.isEnum) {
//            throw IllegalStateException("BasicEnum只能枚举，当前类型: ${scalarType.typeName}")
//        }
//
//        val items = clazz.enumConstants
//        val firstOrNull = items.filter { it. == sqlValue }.firstOrNull()
//            ?: throw IllegalArgumentException("枚举映射失败, 数据库值: ${sqlValue}, 枚举类型: ${scalarType.typeName}")
//        return firstOrNull as BaseEnum<T>?
//    }
//
//    override fun toSql(scalarValue: BaseEnum<T>): Int? {
//        val value = scalarValue.value
//        return value
//    }
//
//    override fun toSql(scalarValue: BasicEnum<T>): Int? {
//        return scalarValue.value
//    }
//
//}